package com.ymatou.riskcontrol.api.testcase;

import java.util.Map;

import org.json.JSONObject;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.ymatou.riskcontrol.api.parameter.RiskOrderPaidBean;
import com.ymatou.riskcontrol.api.service.RiskOrderPaidCall;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.TestCase;
import com.ymt.utils.annotation.TestSuite;
import com.ymt.utils.tag.P1;
import com.ymt.utils.tag.P3;
import com.ymttest.business.service.RiskCallService;
import com.ymttest.utils.constant.ECode;

/**
 * 风控订单付款接口 FreeMaker Template自动生成代码
 */
@TestSuite
public class Ts_RiskOrderPaid {
	private static RiskOrderPaidBean rob;
	private static RiskOrderPaidCall roc;

	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("风控订单付款接口");
	}

	@Before
	public void caseUp() {
		rob = new RiskOrderPaidBean();
		roc = new RiskOrderPaidCall();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(roc.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_RiskOrderPaid_001() {
		Logger.start(true,"风控订单付款校验成功");
		try {
			Map m = RiskCallService.getRiskEsblish();
			// Logger.debug(m);
			rob.setOrderId(m.get("OrderId").toString());
			rob.setPayerId(m.get("PayerId").toString());
			rob.setThirdPartTradingId(m.get("ThirdPartTradingId").toString());
			rob.setTradingId(m.get("TradingId").toString());
			roc.setData(rob);
			roc.callService();
			Logger.comment("RiskOrderPaidCall send:" + roc.getEntityString());
			Logger.comment("RiskOrderPaidCall return:" + roc.getReturnData());
			Logger.verifyEquals(ECode.SUCCESS, roc.getCode(), "验证Code");
			Logger.verifyEquals(ECode.SUCCESSMSG3, roc.getMsg(), "验证Msg");
			Thread.sleep(1000);
			
			//
			JSONObject json = RiskCallService.getRiskDetail(m.get("OrderId").toString());
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P3.class)
	@TestCase
	public void Tc_RiskOrderPaid_002() {
		Logger.start(true,"不输入必填项OrderId失败");
		try {
			Map m = RiskCallService.getRiskEsblish();
			// Logger.debug(m);
			// rob.setOrderId(m.get("OrderId").toString());
			rob.setPayerId(m.get("PayerId").toString());
			rob.setThirdPartTradingId(m.get("ThirdPartTradingId").toString());
			rob.setTradingId(m.get("TradingId").toString());
			roc.setData(rob);
			roc.callService();
			Logger.comment("RiskRechargeCall send:" + roc.getEntityString());
			Logger.comment("RiskRechargeCall return:" + roc.getReturnData());
			Logger.verifyEquals(ECode.ERROR500, roc.getCode(), "验证Code");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
}